module.exports = {
	/**
	 * 初始化账本新增数据
	 */
	initAccountBookInsertParam: async (data) => {
		let _data = await _initAccountBookParam();
		Object.assign(data, _data);
		return data;
	},
	/**
	 * 初始化基础新增数据
	 */
	initBaseInsertParam: async (data) => {
		let _data = await _initBaseParam();
		Object.assign(data, _data);
		return data;
	},
	/**
	 * 初始化基础修改数据
	 */
	dealUpdateParam: async (data) => {
		data.lastUpdateTime = Date.now();
		const revision = data.revision || 0;
		data.revision = revision + 1;
		return data;
	},
}

async function _initAccountBookParam () {
	const date = Date.now();
	let data = {
		"revision" : 0,
		"createTime": date,
		"lastUpdateTime": date,
		"totalCount": 0,
		"totalRevenue": 0,
		"totalEcpenditure": 0,
		"surplus" : 0,
		"totalPersion" : 1
	}
	return data;
}
async function _initBaseParam () {
	const date = Date.now();
	let data = {
		"revision" : 0,
		"createTime": date,
		"lastUpdateTime": date
	}
	return data;
}
